
package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.ordermanager.model.ServicePoint;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import com.eling.elcms.system.model.CommonUser;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Date;
/**
 * 福利消费券
 * @author ly
 * 
 */
@Entity
@Table(name = "travel_welfaredetail")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class, parameter = "operateDate:desc"),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "servicepoint:servicePoint")})
public class WelfareConsumptionCouponDetail  extends BaseModel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7303168864051245891L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	@In
	private Long pkWelfareccd;
	
	/**所属服务点*/
	@ManyToOne(fetch = FetchType.LAZY)
	@In
	@JoinColumn(name = "pkServicePoint")
    @IndexedEmbedded(depth = 1)
	private ServicePoint servicePoint;
	
	/**福利消费券 */
	@ManyToOne(fetch = FetchType.LAZY)
	@In
	@JoinColumn(name = "pkWelfarecc")
    @IndexedEmbedded(depth = 1)
	private WelfareConsumptionCoupon welfareConsumptionCoupon;
	
	/** 经办人 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkOperator")
	@IndexedEmbedded(depth = 1)
	private CommonUser operator;
	
	/** 操作时间 */
	@Column
	@Field
	@Between
	private Date operateDate;
	
	/** 福利消费券状态*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private OperateStatus operateStatus;
	
	/** 取现金额(元) */
	@Field
	@Column
	private Double price;
	
	/** 备注 */
	@Column
	@Field
	private String remarkDetail;
	
	@Version
	private Integer version;
	
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum OperateStatus {
		
		CreditCard("发卡"),Cash("取现"),Loss("挂失"),MendCard("补办"),ReturnCard("退卡"),ReturnCertificate("返券"),Consumption("消费");

		private String display;
		
		OperateStatus(String display) {
			this.display = display;
		}
		
		public String getDisplay() {
			return display;
		}
	}

	public Long getPkWelfareccd() {
		return pkWelfareccd;
	}
	
	public void setPkWelfareccd(Long pkWelfareccd) {
		this.pkWelfareccd = pkWelfareccd;
	}

	public ServicePoint getServicePoint() {
		return servicePoint;
	}

	public void setServicePoint(ServicePoint servicePoint) {
		this.servicePoint = servicePoint;
	}

	public WelfareConsumptionCoupon getWelfareConsumptionCoupon() {
		return welfareConsumptionCoupon;
	}

	public void setWelfareConsumptionCoupon(
			WelfareConsumptionCoupon welfareConsumptionCoupon) {
		this.welfareConsumptionCoupon = welfareConsumptionCoupon;
	}

	public CommonUser getOperator() {
		return operator;
	}
	
	public void setOperator(CommonUser operator) {
		this.operator = operator;
	}
	
	public Date getOperateDate() {
		return operateDate;
	}

	public void setOperateDate(Date operateDate) {
		this.operateDate = operateDate;
	}

	public Double getPrice() {
		return price;
	}
	
	public void setPrice(Double price) {
		this.price = price;
	}

	public String getRemarkDetail() {
		return remarkDetail;
	}

	public void setRemarkDetail(String remarkDetail) {
		this.remarkDetail = remarkDetail;
	}
	
	public Integer getVersion() {
		return version;
	}
	
	public void setVersion(Integer version) {
		this.version = version;
	}

	public OperateStatus getOperateStatus() {
		return operateStatus;
	}
	
	public void setOperateStatus(OperateStatus operateStatus) {
		this.operateStatus = operateStatus;
	}
	
}
